package com.babayetu.myclang03grammaranalysis.model;

import lombok.Builder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

@Data
@Slf4j
public class ASTNode<T> {
    private ASTNode parent;
    private List<ASTNode> children = new ArrayList<ASTNode>();
    private ASTNodeType type;
    private T value;  //节点记录的值，可以减少节点数量

    public ASTNode(ASTNodeType type, T value) {
        this.type = type;
        this.value = value;
    }

    public boolean addChild(ASTNode<T> child) {
        child.parent = this;
        return children.add(child);
    }


}
